package thread;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 28779
 * Date: 2023-08-21
 * Time: 11:14
 */
public class Demo1 {
    public static void main(String[] args) throws InterruptedException {
        Thread t = new Thread(() -> {
            try {
                Thread.sleep(3000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            //System.out.println("执行完毕!!");
        });
        //安排了线程，但还未工作
        System.out.println("状态1；" + t.getState());

        t.start();
        //开始工作，正在执行中
        System.out.println("状态2：" + t.getState());

        Thread.sleep(1000);
        //排队等待中
        System.out.println("状态3：" + t.getState());

        t.join();
        //线程结束，工作完成了
        System.out.println("状态4：" + t.getState());
    }
}
